<script setup lang="ts">
import { ref, onMounted } from 'vue';

const currentTime = ref(new Date().toLocaleString());
const counter = ref(0);

const tableData = [
  {
    date: '2023-05-03',
    name: '张三',
    address: '北京市朝阳区芍药居'
  },
  {
    date: '2023-05-02',
    name: '李四',
    address: '北京市海淀区西二旗'
  },
  {
    date: '2023-05-01',
    name: '王五',
    address: '上海市浦东新区张江'
  },
  {
    date: '2023-04-30',
    name: '赵六',
    address: '广州市天河区天河路'
  }
];

function incrementCounter() {
  counter.value++;
}

onMounted(() => {
  // 每秒更新一次时间
  setInterval(() => {
    currentTime.value = new Date().toLocaleString();
  }, 1000);
});
</script>

<template>
  <div class="test-page">
    <el-card class="mb-16px">
      <template #header>
        <div class="card-header">
          <span class="text-18px font-bold">测试页面</span>
        </div>
      </template>
      <div class="text-gray-700 dark:text-gray-200">
        <p>这是一个测试页面，用于演示客户端路由功能。</p>
        <p class="mt-8px">当前时间: {{ currentTime }}</p>
      </div>
    </el-card>

    <el-card class="mb-16px">
      <template #header>
        <div class="card-header">
          <span class="text-16px font-bold">交互组件</span>
        </div>
      </template>
      <div>
        <p class="mb-16px">计数器: {{ counter }}</p>
        <el-button type="primary" @click="incrementCounter">增加计数</el-button>
      </div>
    </el-card>

    <el-card>
      <template #header>
        <div class="card-header">
          <span class="text-16px font-bold">表格数据</span>
        </div>
      </template>
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="date" label="日期" width="180" />
        <el-table-column prop="name" label="姓名" width="180" />
        <el-table-column prop="address" label="地址" />
      </el-table>
    </el-card>
  </div>
</template>

<style scoped>
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style> 